﻿@using FwProject.PrePaymentInfo.Dto
@using FwProject.PrePaymentInfo
@model PrePaymentInfoEnterDto

@section styles{
    <link href="~/Theme/css/plugins/iCheck/custom.css" rel="stylesheet">
    <link href="~/Theme/css/plugins/datapicker/datepicker3.css" rel="stylesheet">
    <style type="text/css">
        .input-group[class*=col-] {
            padding: 0 15px;
        }

        .checked {
            position: absolute;
            top: 3px;
            left: 220px;
            height: 87px;
            width: 141px;
            background: url('/images/checked.gif') left top no-repeat;
            z-index: 9999;
        }
    </style>
}
<div class="row wrapper wrapper-content animated fadeInRight">
    <div class="col-sm-12">
        <div class="ibox float-e-margins">
            <div class="ibox-title">
                <h5>预收款单</h5>
            </div>
            <div class="ibox-content">
                <div class="row m-b-sm m-t-sm">
                    <form id="form0" class="form-horizontal" asp-controller="Settlement" asp-action="CreateAdvancePayment" data-ajax="true" data-ajax-update="#data_list" data-ajax-method="Post" data-ajax-mode="replace" data-ajax-success="ReloadAjaxCallbackgoback" data-ajax-failure="FailureAjaxCallback">
                        @Html.HiddenFor(o => o.PrePaymentInfoStatus)
                        @Html.HiddenFor(o => o.PrePaymentInfoType)
                        <div class="form-group">
                            <div class="col-md-5">
                                <label class="control-label col-md-3">餐厅</label>
                                <div class="input-group col-md-4">
                                    @Html.TextBoxFor(o => o.RestaurantInfoName, new { @class = "form-control", placeholder = "请选择" })
                                    <div class="input-group-btn">
                                        <button type="button" class="btn btn-white dropdown-toggle" data-toggle="dropdown" style="padding: 6px 12px;">
                                            <span class="caret"></span>
                                        </button>
                                        <ul class="dropdown-menu dropdown-menu-right" id="r" role="menu" style="z-index: 9999;"></ul>
                                    </div>
                                    @Html.HiddenFor(o => o.RestaurantInfoId)
                                    @Html.ValidationMessageFor(o => o.RestaurantInfoName)
                                </div>
                            </div>
                            <div class="col-md-5">
                                <label class="control-label col-md-3">经办人</label>
                                <div class="input-group col-md-4">
                                    @Html.TextBoxFor(o => o.AgentPeoper, new { @class = "form-control", placeholder = "请选择" })
                                    <div class="input-group-btn">
                                        <button type="button" class="btn btn-white dropdown-toggle" data-toggle="dropdown" style="padding: 6px 12px;">
                                            <span class="caret"></span>
                                        </button>
                                        <ul class="dropdown-menu dropdown-menu-right" id="r" role="menu" style="z-index: 9999;"></ul>
                                    </div>
                                    @Html.HiddenFor(o => o.AgentPeoperUserId)
                                    @Html.ValidationMessageFor(o => o.AgentPeoper)
                                </div>
                            </div>
                        </div>
                        <div class="form-group">
                            <div class="col-md-5">
                                <label class="control-label col-md-3">账户</label>
                                <div class="input-group col-md-4">
                                    @Html.DropDownListFor(o => o.CapitalAccountId, ViewBag.Account as IEnumerable<SelectListItem>, new { @class = "form-control" })
                                    @Html.ValidationMessageFor(o => o.CapitalAccountId)
                                </div>
                            </div>
                            <div class="col-md-5">
                                <label class="control-label col-md-3">预收金额</label>
                                <div class="input-group col-md-4">
                                    @Html.TextBoxFor(o => o.PrePaymentPrice, new { @class = "form-control" })
                                    @Html.ValidationMessageFor(o => o.PrePaymentPrice)
                                </div>
                            </div>
                        </div>
                        <div class="form-group">
                            <div class="col-md-5">
                                <label class="control-label col-md-3">备注</label>
                                <div class="input-group col-md-9">
                                    @Html.TextAreaFor(o => o.RemarkContent, new { @class = "form-control", style = "resize:none", rows = 4 })
                                    @Html.ValidationMessageFor(o => o.RemarkContent)
                                </div>
                            </div>
                        </div>
                        <br />
                        <div class="ibox-tools">
                            <button type="button" class="btn btn-primary btn btn-sm submit" data-id="0">保存</button>
                            <button type="button" class="btn btn-primary btn btn-sm submit" data-id="1">提交</button>
                            <button type="button" class="btn btn-primary btn btn-sm"><i class="glyphicon glyphicon-print"></i>打印</button>
                        </div>
                    </form>
                </div>


            </div>
        </div>
    </div>
</div>
@section scripts{
    <script src="~/Theme/js/content.min.js?v=1.0.0"></script>
    <script src="~/Theme/js/plugins/iCheck/icheck.min.js"></script>
    <script src="~/Theme/js/plugins/suggest/bootstrap-suggest2014.js"></script>
    <script>
        $(document).ready(function () {
            //绑定餐厅
            $.getJSON("/Restaurant/GetSuggestData").done(function (data) {
                CommonAjaxCallback(data, function () {
                    bindSuggest(data.result);
                }, null);
            }).fail(function () {
                layer.msg('连接超时，获取餐厅信息失败！', {
                    icon: 2,
                    time: 2000
                });
            });

            //绑定经办人
            $.getJSON("/Users/GetSuggestData2").done(function (data) {
                CommonAjaxCallback(data, function () {
                    bindUserSuggest(data.result);
                }, null);
            }).fail(function () {
                layer.msg('连接超时，获取经办人信息失败！', {
                    icon: 2,
                    time: 2000
                });
            });

            $(".submit").on("click", function () {
                var s = $(this).data("id");
                $("#PrePaymentInfoStatus").val(s);
                $("#form0").submit();
            });
        });


        function bindSuggest(data) {
            if ($("#RestaurantInfoName") != undefined) {
                $("#RestaurantInfoName").bsSuggest({
                    effectiveFields: ["restaurantName"],
                    effectiveFieldsAlias: { "restaurantName": "名称" },
                    searchFields: ["restaurantName"],
                    clearable: true,
                    getDataMethod: "data",
                    //url: "/Users/GetSuggestData?type=司机类型&keyword=",
                    data: { value: data },
                    idField: "id",
                    keyField: "restaurantName",
                }).on('onDataRequestSuccess', function (e, result) {
                    console.log('onDataRequestSuccess: ', result);
                }).on('onSetSelectValue', function (e, keyword, data) {
                    $("#RestaurantInfoId").val(data.id);
                    console.log('onSetSelectValue: ', keyword, data);
                }).on('onUnsetSelectValue', function () {
                    console.log('onUnsetSelectValue');
                });
            }
        }

        function bindUserSuggest(data) {
            if ($("#AgentPeoper") != undefined) {
                $("#AgentPeoper").bsSuggest({
                    effectiveFields: ["name", "mobile"],
                    effectiveFieldsAlias: { "name": "姓名", "mobile": "电话" },
                    searchFields: ["name"],
                    clearable: true,
                    getDataMethod: "data",
                    //url: "/Users/GetSuggestData?type=司机类型&keyword=",
                    data: { value: data },
                    idField: "id",
                    keyField: "name",
                }).on('onDataRequestSuccess', function (e, result) {
                    console.log('onDataRequestSuccess: ', result);
                }).on('onSetSelectValue', function (e, keyword, data) {
                    $("#AgentPeoperUserId").val(data.id);
                    console.log('onSetSelectValue: ', keyword, data);
                }).on('onUnsetSelectValue', function () {
                    console.log('onUnsetSelectValue');
                });
            }
        }

        function ReloadAjaxCallbackgoback(data, successInfo) {
            CommonAjaxCallback(data, function () {
                window.location = '/Settlement/EditAdvancePayment/' + data.result;
            }, successInfo);
        }
    </script>
}




